$()
		.ready(function() {

			// validate signup form on keyup and submit
				$("#changeAccount")
						.validate(
								{
									rules : {
										username : {
											required : true,
											minlength : 2
										},
										password : {
											required : true,
											minlength : 5
										},
										new_password : {
											required : true,
											minlength : 5
										},
										confirm_password : {
											required : true,
											minlength : 5,
											equalTo : "#new_password"
										}
									},

									messages : {
										username : {
											required : "Completati username-ul",
											minlength : "Username-ul dvs trebuie sa contina cel putin 2 caractere"
										},
										password : {
											required : "Introduceti parola",
											minlength : "Parola trebuie sa aibe cel putin 5 caractere"
										},
										new_password : {
											required : "Introduceti noua parola",
											minlength : "Parola trebuie sa aibe cel putin 5 caractere"
										},
										confirm_password : {
											required : "Introduceti noua parola",
											minlength : "Parola trebuie sa aibe cel putin 5 caractere",
											equalTo : "Parolele nu coincid"
										}
									}
								});

				// propose username by combining first- and lastname
				$("#username").focus(function() {
					var firstname = $("#firstname").val();
					var lastname = $("#lastname").val();
					if (firstname && lastname && !this.value) {
						this.value = firstname + "." + lastname;
					}
				});

			});
